# -*- encoding: utf-8 -*-
from shapely.wkt import loads as wkt_loads
import dsl
from . import FixtureTest


class KindCsv(FixtureTest):
    def test_post_office(self):
        self.generate_fixtures(dsl.way(1223019595, wkt_loads('POINT (-122.397912377293 37.79398981061289)'), {u'operator': u'FedEx', u'opening_hours': u'24/7', u'amenity': u'post_office', u'name': u'FedEx 24h office', u'source': u'openstreetmap.org'}))  # noqa

        self.assert_has_feature(
            16, 10486, 25326, 'pois',
            {'kind': 'post_office'})

    def test_museum(self):
        self.generate_fixtures(dsl.way(317081601, wkt_loads('POINT (-122.401133196913 37.78179628685439)'), {u'addr:housenumber': u'300', u'name': u'California Society of Pioneers Museum and Library', u'wheelchair': u'no', u'source': u'openstreetmap.org', u'tourism': u'museum', u'addr:street': u'4th Street'}))  # noqa

        self.assert_has_feature(
            16, 10485, 25329, 'pois',
            {'kind': 'museum'})

    def test_gate(self):
        self.generate_fixtures(dsl.way(3910307149, wkt_loads('POINT (-122.387808486304 37.78211137673449)'), {u'source': u'openstreetmap.org', u'barrier': u'gate'}),dsl.way(387798241, wkt_loads('LINESTRING (-122.387808486304 37.78211137673449, -122.387808486304 37.78236817612337, -122.385557038707 37.7825013678243)'), {u'access': u'private', u'source': u'openstreetmap.org', u'highway': u'footway'}))  # noqa

        self.assert_has_feature(
            16, 10487, 25329, 'pois',
            {'kind': 'gate'})

    def test_enclosure(self):
        self.generate_fixtures(dsl.way(382798035, wkt_loads('POLYGON ((-122.503372166198 37.73355182054999, -122.503351415115 37.7335692975289, -122.503319345259 37.73358741390509, -122.503269578592 37.73359366582999, -122.503222686534 37.73360219118118, -122.503193221793 37.73359160553661, -122.503151000975 37.73358997151079, -122.503103300433 37.73359480254348, -122.503081201877 37.73358677450361, -122.503069793273 37.73356766350251, -122.503069074621 37.73354436086258, -122.503095305427 37.73352688387778, -122.503122075223 37.7335204898579, -122.503127914272 37.7335188558305, -122.503133483827 37.73350777286118, -122.503168428291 37.73349619257738, -122.503180465716 37.73347175319959, -122.503184508135 37.73343566247561, -122.503220710241 37.73344951620049, -122.503260864934 37.73346010186538, -122.503280987196 37.73346010186538, -122.503303804404 37.73346010186538, -122.503307218003 37.73344901888728, -122.503346115054 37.73344738485829, -122.503360218604 37.73347019021578, -122.503368932263 37.73350677823569, -122.503372166198 37.73355182054999))'), {u'name': u'Flamingo', u'attraction': u'animal', u'way_area': u'529.71', u'zoo': u'enclosure', u'source': u'openstreetmap.org', u'tourism': u'attraction', u'name:es': u'Flamenco Chileno'}),dsl.way(382798029, wkt_loads('POLYGON ((-122.504368038522 37.73285415891728, -122.504357258738 37.73287540146119, -122.504334531361 37.73287859849898, -122.504325099051 37.73289657295371, -122.504330488943 37.73292001788798, -122.504321146464 37.73297188089818, -122.504331836416 37.73301536054451, -122.504360043516 37.7330429971038, -122.504363996103 37.7330737596371, -122.504333094057 37.73310452215762, -122.504276769689 37.73315645608349, -122.504217840206 37.73322970346028, -122.504142741048 37.7332466121558, -122.504039434791 37.7332265064376, -122.503997932625 37.73320739534346, -122.503950860904 37.73320100129609, -122.503914658798 37.73318942096429, -122.503865341289 37.73317961675559, -122.50384836313 37.7331789063056, -122.503862915837 37.73307901697402, -122.503965593274 37.7330429971038, -122.503974306933 37.7330577034435, -122.504028475344 37.7330383791704, -122.504001975043 37.73298701352309, -122.504007364935 37.7329752200223, -122.504060006211 37.73295617990847, -122.504069079195 37.73297166776259, -122.50408641668 37.7329652026496, -122.504120642492 37.7329573166319, -122.504108066078 37.7329292537692, -122.504115342432 37.7329093611006, -122.504144178353 37.7328994147643, -122.50412225946 37.73285977149638, -122.504104472817 37.73286588139209, -122.504087045501 37.73283440831919, -122.504120193335 37.73276336295869, -122.504145435994 37.7327650680481, -122.504184333046 37.73275661364588, -122.504219097847 37.73272691666229, -122.504263384791 37.7327226539364, -122.504287459641 37.7327301137065, -122.504303629316 37.73274709356149, -122.504327793997 37.73275029060489, -122.504339831422 37.73275128524059, -122.504339831422 37.7327724567686, -122.504366691049 37.7328064875006, -122.504368038522 37.73285415891728))'), {u'natural': u'grassland', u'name': u'Lemur Forest', u'attraction': u'animal', u'way_area': u'2387.65', u'zoo': u'enclosure', u'source': u'openstreetmap.org', u'tourism': u'attraction', u'species': u'Lemur', u'name:es': u'Bosque del L\xe9mur'}))  # noqa

        self.assert_has_feature(
            16, 10466, 25340, 'pois',
            {'kind': 'enclosure'})

    def test_forest(self):
        self.generate_fixtures(dsl.way(422270533, wkt_loads('POLYGON ((-122.450519157636 37.8047972988937, -122.450366174543 37.80501349215022, -122.450113208959 37.80504365695018, -122.449879287659 37.80533657426129, -122.449729269006 37.80561898604738, -122.449439472496 37.8055701549336, -122.448976121472 37.80544459920371, -122.448833469005 37.80589791897051, -122.448565681219 37.80598848322479, -122.448440725563 37.80517269117898, -122.449436508055 37.8049494717574, -122.450519157636 37.8047972988937))'), {u'way_area': u'15894.9', u'source': u'openstreetmap.org', u'landuse': u'forest'}))  # noqa

        self.assert_has_feature(
            16, 10476, 25324, 'landuse',
            {'id': 422270533, 'kind': 'forest'})

    def test_substation(self):
        self.generate_fixtures(dsl.way(274459420, wkt_loads('POLYGON ((-122.44078222844 37.78184960657469, -122.440502762555 37.78188467971199, -122.440509410088 37.7819176228866, -122.440448144985 37.7819252906923, -122.440430358343 37.7818373238729, -122.440300821279 37.78185351147948, -122.440286987223 37.781784714127, -122.440543546069 37.78175262287358, -122.440757345106 37.78172578548729, -122.44078222844 37.78184960657469))'), {u'building': u'yes', u'name': u'Station G', u'power': u'sub_station', u'way_area': u'854.035', u'source': u'openstreetmap.org', u'operator': u'Pacific Gas & Electric'}),dsl.way(274459406, wkt_loads('POLYGON ((-122.440757345106 37.78172578548729, -122.440543546069 37.78175262287358, -122.44052306448 37.78165088214839, -122.440510577898 37.7815886164716, -122.44050599649 37.78156547095008, -122.440494318391 37.78150718112288, -122.440491982771 37.7814958213461, -122.440483538608 37.78145336416499, -122.440482191135 37.78144718728208, -122.440695990172 37.78142042078348, -122.440757345106 37.78172578548729))'), {u'building': u'yes', u'addr:housenumber': u'1200', u'name': u'Station G', u'power': u'sub_station', u'way_area': u'1049.49', u'source': u'openstreetmap.org', u'operator': u'Pacific Gas & Electric', u'addr:street': u'Broderick Street'}))  # noqa

        self.assert_has_feature(
            16, 10478, 25329, 'landuse',
            {'kind': 'substation'})
